<?php
/**
 * DESC:只有在登录之后才能查看的可以引用
 * 作者:晨光
 * EMAIL:461718846@qq.com
 * DATE:2020/4/5
 */

namespace app\common\controller;


use EasyWeChat\Factory;
use think\facade\Request;

class WechatUserBase extends WechatBase
{
//    引入中间件
    protected $middleware = ['app\http\middleware\Wechat'];
    protected $wxJssdkArr = ['chooseImage','updateAppMessageShareData','updateTimelineShareData','onMenuShareWeibo','previewImage','uploadImage','getLocalImgData','downloadImage','getNetworkType','openLocation','getLocation','scanQRCode','chooseWXPay','openAddress'];

    public function initialize(){

        $wechatConfig = config('wechat.');
        $app = Factory::officialAccount($wechatConfig);

        $url = Request::url(true);
        $this->assign('url',$url);

        $domain = Request::domain();
        $this->assign('domain',$domain);

        $app->jssdk->setUrl($url);
        $jssdk = $app->jssdk->buildConfig($this->wxJssdkArr, false);
        $this->assign('jssdk',$jssdk);

        $this->assign('user_id',session('wechat.id'));

        parent::initialize(); // TODO: Change the autogenerated stub
    }
}
